﻿Imports System.Data.OleDb

Public Class ExpensesDAO
    Public Function Expenses_Exists(ByVal ImportItemID As Integer) As Boolean
        Dim para(1) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Boolean

        para(1) = New OleDbParameter("@Exists", OleDbType.Boolean)
        para(1).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedure("spTDT_Expenses_Exists", para)
        Return para(1).Value
    End Function

    Public Function Expenses_ImportItems_Delete(ByVal ImportItemID As Integer) As Boolean
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Expenses_ImportItems_Delete", para)
    End Function

    Public Function Expenses_Insert(ByVal ImportItemID As Integer, _
                                    ByVal Description As String, _
                                    ByVal Price As Double, _
                                    ByVal PricebyText As String, _
                                    ByVal RateOfExchange As Integer, _
                                    ByVal ExpensesDate As Date, _
                                    ByVal ExpensesBy As Integer, _
                                    ByVal CreatedBy As String) As Boolean
        Dim para(7) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@Description", Description)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@Price", Price)
        para(2).OleDbType = OleDbType.Double

        para(3) = New OleDbParameter("@PricebyText", PricebyText)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@RateOfExchange", RateOfExchange)
        para(4).OleDbType = OleDbType.Integer

        para(5) = New OleDbParameter("@ExpensesDate", ExpensesDate)
        para(5).OleDbType = OleDbType.Date

        para(6) = New OleDbParameter("@ExpensesBy", ExpensesBy)
        para(6).OleDbType = OleDbType.Integer

        para(7) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(7).OleDbType = OleDbType.VarWChar

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Expenses_Insert", para)
    End Function

    Public Function Expenses_List() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Expenses_List", Nothing)
    End Function

    Public Function Expenses_Delete(ByVal ExpensesID As Integer) As Boolean
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ExpensesID", ExpensesID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Expenses_Delete", para)
    End Function
End Class
